package com.shengyijie.adapter.viewadapter;

import java.util.List;
 
import com.shengyijie.activity.R;
import com.shengyijie.adapter.asyncimageadapter.AsyncImageLoader;
import com.shengyijie.adapter.asyncimageadapter.AsyncImageLoader.ImageCallback;
import com.shengyijie.adapter.viewcache.CategoryListViewCache; 
import com.shengyijie.adapter.viewcache.GBListViewCache;
import com.shengyijie.adapter.viewcache.ItemListViewCache;
import com.shengyijie.context.ContextApplication;
import com.shengyijie.model.object.baseobject.Category;
import com.shengyijie.model.object.baseobject.GuesstBook;
import com.shengyijie.model.object.baseobject.Item;
import com.shengyijie.util.Utility;


import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter; 
import android.widget.ImageView;
import android.widget.ListView; 
import android.widget.TextView;


public class GBListAdapter extends ArrayAdapter<GuesstBook>{
  
	
	public GBListAdapter(Activity activity, List<GuesstBook> newsList,ListView listView) {
		  super(activity, 0, newsList); 
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent){
		GBListViewCache viewCache;
		try{ 
				if (convertView == null) {
					LayoutInflater inflater = ((Activity) this.getContext()).getLayoutInflater(); 
					convertView = inflater.inflate(R.layout.gblistcell, null);  
					viewCache = new GBListViewCache(convertView);
					convertView.setTag(viewCache);
				}else{
					viewCache = (GBListViewCache) convertView.getTag(); 
				}  
				try{ 
					GuesstBook content=(GuesstBook)getItem(position);
					TextView name = viewCache.getName();   
					name.setText(content.getName());
					
					TextView Id = viewCache.getID();   
					Id.setText(content.getId());
					
					TextView time = viewCache.getTime();   
					time.setText(content.getTime());
					
					TextView satus = viewCache.getStatus();   
					if(content.getStatus()==0){
						satus.setText("未读");
					}else if(content.getStatus()==1){
						satus.setText("已读");
					}else{
						satus.setText("已删除");
					}
					
//					TextView time = viewCache.getName();   
//					name.setText(getItem(position).getTime());
					
					 
					
				}catch(Exception e){}
		}catch(Exception e){}
		return convertView;
	}
}
